<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>用户维护界面</title>
<base target="_self" />
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/lib/jquery/jquery-1.7.min.js"></script>
<script type="text/javascript">
//--------弹出窗口---------	
function xiugai(obj){
	var backvalue = window.showModalDialog('<%=basePath %>sys/user_selectByUserID.action?time='+new Date()+'&user.id='+obj,window,'dialogWidth:650px; dialogHeight:500px; status:no; resizable:yes;scroll:no;');
	if(backvalue == 'success'){
		window.location.reload(true);
	}
}

//改变用户状态
function changeUserStatus(userId, state){
	var params = {
			ct : new Date(),
			'user.id': userId,
			'user.state': state
	};
	$.getJSON('sys/user_changeUserStatus.action', params, function(json){
		if(json.resultCode == 'success'){
			window.location.reload(true);
		}else{
			alert("改变用户状态失败，请联系管理员！");
		}
	});
}
</script>
</head>

<body>
<form action="<%=basePath %>/sys/user_selectUser.action" id="form2" method="post">
	<div class="EnterBorder">
		
  		<table width="100%" border="1" cellspacing="0" cellpadding="5">
    		<tr>
      			<td colspan="8" class="tabTitle">搜索区</td>
    		</tr>
    		<tr>
		    	<td align="right">登&nbsp;&nbsp;录&nbsp;&nbsp;名</td>
		      	<td><input name="user.uname" type="text" value="<s:property value="%{user.uname}" />" /></td>
		      	<td align="right">姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名</td>
		      	<td><input name="user.rname" type="text" value="<s:property value="%{user.rname}" />" /></td>
		      	<td align="right">手&nbsp;&nbsp;机&nbsp;&nbsp;号</td>
		      	<td><input name="user.phone" type="text" value="<s:property value="%{user.phone}" />" /></td>
		      	<td align="right">状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态</td>
		      	<td><select name="user.state" id="state" class="optionStyle">
        				<option value="">---请选择---</option>
        				<option value="1" <s:if test="%{user.state == 1}">selected</s:if>>启用</option>
        				<option value="2" <s:if test="%{user.state == 2}">selected</s:if>>停用</option>
      				</select><input type="submit" value="确定" />
				</td>
    		</tr>
  		</table>
  		
	</div>
	<div class="tabBorder">
		<table width="100%" border="1" cellspacing="0" cellpadding="5">
  			<tr>
    			<td colspan="8" class="tabTitle">搜索列表</td>
  			</tr>
  			<tr>
			    <td align="center" class="tabHeader1">登录名 </td>
			    <td align="center" class="tabHeader2">姓名</td>
			    <td align="center" class="tabHeader2">手机号</td>
			    <td align="center" class="tabHeader2">状态</td>
			    <td align="center" class="tabHeader2">操作</td>
  			</tr>
  			<s:iterator value="%{pm.list}">
  			<tr onmouseover ="this.style.backgroundColor='#cef6f6'" onmouseout= "this.style.backgroundColor='#fff'">
			    <td align="center" class="tabTd1">&nbsp;<s:property value="%{uname}" /></td>
			    <td align="center" class="tabTd2">&nbsp;<s:property value="%{rname}" /></td>
			    <td align="center" class="tabTd2">&nbsp;<s:property value="%{phone}" /></td>
			    <td align="center" class="tabTd2">&nbsp;
			    	<s:if test="%{state == 1}">启用</s:if>
			    	<s:if test="%{state == 2}">停用</s:if>
			    </td>
			    <td align="center" class="tabTd2">
			    	<a href="javascript:void(0);" onclick="xiugai('<s:property value="%{id}" />')">修改</a>&nbsp;|&nbsp;
			    	<a href="<%=basePath %>sys/user_deleteUser.action?user.id=<s:property value='%{id}' />" onclick="return confirm('确认要删除用户 <s:property value='%{uname}' /> 吗?')">删除</a>&nbsp;|&nbsp;
			    	<s:if test="%{state == 1}"><a href="javascript:void(0);" onclick="changeUserStatus('${id}', '2');">停用</a></s:if>
			    	<s:if test="%{state == 2}"><a href="javascript:void(0);" onclick="changeUserStatus('${id}', '1');">启用</a></s:if>&nbsp;|&nbsp;
			    </td>
  			</tr>
  			</s:iterator>
  			<tr >
				<td class="TableTdStyleRight2" colspan="5">${pm.pageHtml }</td>
     		</tr>
		</table>
	</div>
	</form>
</body>
</html>